#include<iostream>
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
int n,m1,m2;
struct leo{
	int r;
	int u;
	int v;
	int b;
};
leo hb1[100005],hb2[100005];
int ans1[100005],ans2[100005];
int F(int x){
	if(x==m1) return x;
	if(!hb1[x].b)return x;
	return hb1[x].r=F(hb1[x].r);
}
int F2(int x){
	if(x==m2) return x;
	if(!hb2[x].b)return x;
	return hb2[x].r=F2(hb2[x].r);
}
void erfen1(){
	int l=1,r=m1;int cnt=0;
	int x=0,i=0;
	while(cnt<m1&&i<n){
		x=0;	l=0;
		while(l<m1){
		
			l=F(l+1);r=m1;
			while(l<r){
				int mid=(l+r)>>1;
				if(hb1[mid].u>x)r=mid;
				else l=mid+1;
			}
			if(l==m1) break;
			l=F(l);
			if(hb1[l].u>x&&hb1[l].b==0){
			//	cout<<l<<' ';
				hb1[l].b=1; cnt++;
				// boy next door do a game
				x=hb1[l].v;//cout<<1;
			
			}
			
		}
		if(hb1[m1].u>x&&hb1[m1].b==0) hb1[m1].b=1,cnt++;

		ans1[++i]=cnt;
	//	cout<<1;
	}
//	for(int k=1;k<=n;k++) cout<<ans1[k]<<' ';	cout<<endl;
}
void erfen2(){
	int l=1,r=m2;int cnt=0;	int x=0,j=0;
	while(cnt<m2&&j<n){
		x=0;	l=0;
		while(l<m2){
			l=F2(l+1);r=m2;
			while(l<r){
				int mid=(l+r)>>1;
				if(hb2[mid].u>x)r=mid;
				else l=mid+1;//cout<<1;
			}
			if(l==m2) break;
			l=F2(l);
			if(hb2[l].u>x&&hb2[l].b==0){
//				cout<<l<<' ';
				hb2[l].b=1; cnt++;
				// boy next door do a game
				x=hb2[l].v;//cout<<1;
			}
		}
		if(hb2[m2].u>x&&hb2[m2].b==0) hb2[m2].b=1,cnt++;
		ans2[++j]=cnt;
	}
//	for(int k=1;k<=n;k++) cout<<ans2[k]<<' ';	cout<<endl;
}
bool cmp(leo A,leo B){
	return A.u<B.u;
}
signed main(){
	freopen("airport.in","r",stdin);
	freopen("airport.out","w",stdout);
	cin>>n>>m1>>m2;
	for(int i=1;i<=m1;i++)	cin>>hb1[i].u>>hb1[i].v;	
	for(int i=1;i<=m2;i++)	cin>>hb2[i].u>>hb2[i].v;
	sort(hb1+1,hb1+1+m1,cmp);	for(int i=1;i<=m1;i++) hb1[i].r=i+1;
	sort(hb2+1,hb2+1+m2,cmp);	for(int i=1;i<=m2;i++) hb2[i].r=i+1;
	erfen1();
	erfen2();
	int ans=0;
	for(int k=0;k<=n;k++)
		ans=max(ans,ans1[k]+ans2[n-k]);
	cout<<ans;
	return 0;
}
